package com.woniuxy.oldmanapi.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.oldmanapi.entity.Consulter;
import com.woniuxy.oldmanapi.entity.Cost;
import com.woniuxy.oldmanapi.entity.Othercost;
import com.woniuxy.oldmanapi.mapper.CostMapper;
import com.woniuxy.oldmanapi.mapper.OthercostMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CostService {
    @Autowired
    CostMapper costMapper;

    //查询咨询者信息
    public PageInfo<Cost> selectCost(int now, int size, String cname) {
        PageHelper.startPage(now,size);
        List<Cost> consulterList = costMapper.selectCostByName(cname);
        PageInfo<Cost> pageInfo = new PageInfo<>(consulterList);
        return pageInfo;
    }

    //更新咨询者信息
    public void updateCost(Cost consulter) {
        costMapper.updateByPrimaryKey(consulter);
    }

    //删除咨询者信息
    public void deleteCost(int consulter) {
        costMapper.deleteByPrimaryKey(consulter);
    }

    //新增咨询者信息
    public void insertCost(Cost consulter) {
        costMapper.insertCost(consulter.getType(),consulter.getName());
    }
}
